<template>
  <view class="tn-padding-sm">
    <tn-collapse hoverClass="none" ref="collapse">
      <tn-collapse-item title="拖车收费" :class="{'active':tcSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="故障事故车型：" prop="tcCarType">
              <tn-input type="select" :selectOpen="chexingSelectShow"
                        @click="selectType = 'tc',chexingSelectShow = true,chexingList = chexing"
                        v-model="form.tcCarType"/>
            </tn-form-item>
            <tn-form-item label="公里数：" prop="tcKm">
              <tn-input type="number" v-model="form.tcKm" @input="handleInput"/>
            </tn-form-item>
            <tn-form-item label="上浮20%：" prop="tcIsUp">
              <tn-radio-group v-model="form.tcIsUp">
                <tn-radio v-for="(item, index) in isUpLst" :key="index" :name="item.name">
                  {{ item.name }}
                </tn-radio>
              </tn-radio-group>
            </tn-form-item>
            <tn-form-item label="基价：" prop="tcBasePrice">
              <tn-input type="number" v-model="form.tcBasePrice"/>
              <text class="tn-color-gray">元/车次</text>
            </tn-form-item>
            <tn-form-item label="作业费：" prop="tcHomework">
              <tn-input v-model="form.tcHomework" disabled/>
              <text class="tn-color-gray">元</text>
            </tn-form-item>
            <tn-form-item label="小计：" prop="tcSubtotal">
              <tn-input type="number" v-model="tcSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>
      <tn-collapse-item title="吊车收费" :class="{'active':dcSubtotal>0}">
        <diaocheCom @collapseInit="collapseInit" :total.sync="dcSubtotal" ref="diaoche"></diaocheCom>
      </tn-collapse-item>

      <tn-collapse-item title="换轮胎" :class="{'active':hltSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">

            <tn-form-item label="类型：" prop="hlt2DownOrhlt2Up">
              <tn-input type="select" :selectOpen="huantaiSelectShow" @click="huantaiSelectShow = true"
                        v-model="form.hlt2DownOrhlt2Up"/>
            </tn-form-item>

            <tn-form-item label="数量：" prop="hltCount">
              <tn-input type="number" v-model="form.hltCount"/>
              <text class="tn-color-gray">条</text>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="hltChargingStandard">
              <tn-input v-model="form.hltChargingStandard"/>
              <text class="tn-color-gray">元/条</text>
            </tn-form-item>
            <tn-form-item label="上浮20%：" prop="hltIsUp">
              <tn-radio-group v-model="form.hltIsUp">
                <tn-radio v-for="(item, index) in isUpLst" :key="index" :name="item.name">
                  {{ item.name }}
                </tn-radio>
              </tn-radio-group>
            </tn-form-item>
            <tn-form-item label="小计：" prop="hltSubtotal">
              <tn-input type="number" v-model="hltSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="车辆整修费" :class="{'active':clzxJqsSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <view class="tn-text-center tn-padding-sm font-weight-bold">卸半轴，解气刹</view>
            <tn-form-item label="数量：" prop="clzxJqsCount">
              <tn-input type="number" v-model="form.clzxJqsCount"/>
              <text class="tn-color-gray">次</text>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="clzxJqsChargingStandard">
              <tn-input v-model="form.clzxJqsChargingStandard"/>
              <text class="tn-color-gray">元/次</text>
            </tn-form-item>
            <tn-form-item label="上浮20%：" prop="clzxJqsIsUp">
              <tn-radio-group v-model="form.clzxJqsIsUp">
                <tn-radio v-for="(item, index) in isUpLst" :key="index" :name="item.name">
                  {{ item.name }}
                </tn-radio>
              </tn-radio-group>
            </tn-form-item>
            <tn-form-item label="小计：" prop="clzxJqsSubtotal">
              <tn-input type="number" v-model="clzxJqsSubtotal"/>
            </tn-form-item>

            <view class="tn-text-center tn-padding-sm font-weight-bold">气割，焊</view>
            <tn-form-item label="数量：" prop="clzxQgCount">
              <tn-input type="number" v-model="form.clzxQgCount"/>
              <text class="tn-color-gray">小时</text>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="clzxQgChargingStandard">
              <tn-input v-model="form.clzxQgChargingStandard"/>
              <text class="tn-color-gray">元/次小时</text>
            </tn-form-item>
            <tn-form-item label="上浮20%：" prop="clzxQgIsUp">
              <tn-radio-group v-model="form.clzxQgIsUp">
                <tn-radio v-for="(item, index) in isUpLst" :key="index" :name="item.name">
                  {{ item.name }}
                </tn-radio>
              </tn-radio-group>
            </tn-form-item>
            <tn-form-item label="小计：" prop="clzxQgSubtotal">
              <tn-input type="number" v-model="clzxQgSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="货物装卸费" :class="{'active':hwzxJxzxSubtotal>0}">
        <huowuzhuangxieCom @collapseInit="collapseInit" :total.sync="hwzxJxzxSubtotal"
                           ref="huowuzhuangxie"></huowuzhuangxieCom>
      </tn-collapse-item>

      <tn-collapse-item title="货物转运费" :class="{'active':hwyzSubtotal>0}">
        <huowuzhuanyunCom @collapseInit="collapseInit" :total.sync="hwyzSubtotal"
                          ref="huowuzhuanyun"></huowuzhuanyunCom>
      </tn-collapse-item>

      <tn-collapse-item title="搭电" :class="{'active':ddSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="故障事故车型：" prop="ddCarType">
              <tn-input type="select" :selectOpen="dadianSelectShow"
                        @click="selectType = 'dadian',dadianSelectShow = true"
                        v-model="form.ddCarType"/>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="ddChargingStandard">
              <tn-input v-model="form.ddChargingStandard"/>
              <text class="tn-color-gray">元/次</text>
            </tn-form-item>
            <tn-form-item label="小计：" prop="ddSubtotal">
              <tn-input type="number" v-model="ddSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="送水" :class="{'active':ssSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="故障事故车型：" prop="ssCarType">
              <tn-input type="select" :selectOpen="dadianSelectShow"
                        @click="selectType = 'songshui',dadianSelectShow = true"
                        v-model="form.ssCarType"/>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="ssChargingStandard">
              <tn-input v-model="form.ssChargingStandard"/>
              <text class="tn-color-gray">元/次</text>
            </tn-form-item>
            <tn-form-item label="小计：" prop="ssSubtotal">
              <tn-input type="number" v-model="ssSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="车辆保管费" :class="{'active':clbgSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="故障事故车型：" prop="clbgCarType">
              <tn-input type="select" :selectOpen="dadianSelectShow"
                        @click="selectType = 'cheliangbaoguanfei',dadianSelectShow = true"
                        v-model="form.clbgCarType"/>
            </tn-form-item>
            <tn-form-item label="收费标准：" prop="clbgChargingStandard">
              <tn-input v-model="form.clbgChargingStandard"/>
              <text class="tn-color-gray">元/天</text>
            </tn-form-item>
            <tn-form-item label="保管天数：" prop="clbgCustody">
              <tn-input v-model="form.clbgCustody"/>
            </tn-form-item>
            <tn-form-item label="载有货物(加价50%)：" prop="clbgGoods">
              <tn-radio-group v-model="form.clbgGoods">
                <tn-radio v-for="(item, index) in isUpLst" :key="index" :name="item.name">
                  {{ item.name }}
                </tn-radio>
              </tn-radio-group>
            </tn-form-item>
            <tn-form-item label="小计：" prop="clbgSubtotal">
              <tn-input type="number" v-model="clbgSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="事故现场清理" :class="{'active':form.sgxcqlSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="内容：" prop="sgxcqlContent">
              <tn-input type="text" v-model="form.sgxcqlContent"/>
            </tn-form-item>
            <tn-form-item label="小计：" prop="sgxcqlSubtotal">
              <tn-input type="number" v-model="form.sgxcqlSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="车辆通行费" :class="{'active':form.cltxSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="内容：" prop="cltxContent">
              <tn-input type="text" v-model="form.cltxContent"/>
            </tn-form-item>
            <tn-form-item label="小计：" prop="cltxSubtotal">
              <tn-input type="number" v-model="form.cltxSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>

      <tn-collapse-item title="其他收费" :class="{'active':form.qtSubtotal>0}">
        <view class="card tn-padding-sm tn-margin-sm">
          <tn-form :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
            <tn-form-item label="内容：" prop="qtContent">
              <tn-input type="text" v-model="form.qtContent"/>
            </tn-form-item>
            <tn-form-item label="小计：" prop="qtSubtotal">
              <tn-input type="number" v-model="form.qtSubtotal"/>
            </tn-form-item>
          </tn-form>
        </view>
      </tn-collapse-item>
    </tn-collapse>

    <view class="tn-text-center tn-color-red tn-margin-sm">合计：{{ sumMoneyLower_com }} 元</view>
    <tn-form class="card tn-padding-sm" :model="form" ref="form" :labelWidth="220" :errorType="['message', 'toast']">
      <tn-form-item label="司乘人员签字：" prop="party">
        <image class="signImg" @click="jupmSign('party')" :src="form.party" mode=""></image>
      </tn-form-item>
      <tn-form-item label="司乘人员联系方式：" prop="partyTel">
        <tn-input type="number" v-model="form.partyTel"/>
      </tn-form-item>
      <tn-form-item label="救援单位(签字)：" prop="rescueUnit">
        <image class="signImg" @click="jupmSign('rescueUnit')" :src="form.rescueUnit" mode=""></image>
      </tn-form-item>
      <tn-form-item label="救援单位联系方式：" prop="rescueUnitTel">
        <tn-input type="number" v-model="form.rescueUnitTel"/>
      </tn-form-item>
      <tn-form-item label="保通保畅应急大队(签字)：" prop="emerg">
        <image class="signImg" @click="jupmSign('emerg')" :src="form.emerg" mode=""></image>
      </tn-form-item>
      <tn-form-item label="保通保畅应急大队联系方式：" prop="emergTel">
        <tn-input type="number" v-model="form.emergTel"/>
      </tn-form-item>
      <tn-form-item label="时间：" prop="createTime1">
        <uni-datetime-picker :clearIcon="false" :border="false" placeholder="请选择时间"
                             v-model="form.createTime1"/>
      </tn-form-item>
    </tn-form>
    <view class="tn-flex tn-flex-row-center tn-padding-xl">
      <tn-button @click="submit" backgroundColor="tn-bg-blue" style="width: 80%" fontColor="tn-color-white">保存
      </tn-button>
    </view>

    <!-- 换胎select -->
    <view v-show="huantaiSelectShow">
      <tn-select v-model="huantaiSelectShow" mode="single" :list="huantaiList" @confirm="huantaiConfirm"></tn-select>
    </view>

    <!-- 车型select -->
    <view v-show="chexingSelectShow">
      <tn-select v-model="chexingSelectShow" mode="single" :list="chexingList" @confirm="chexingConfirm"></tn-select>
    </view>


    <!-- 搭电 送水 车辆保管费 select -->
    <view v-show="dadianSelectShow">
      <tn-select v-model="dadianSelectShow" mode="single" :list="dadianList" @confirm="dadianConfirm"></tn-select>
    </view>

    <tn-modal v-model="erweima" :custom="true">
      <view class="modal-box" style="max-height: 100vw;padding-top: 32px;">
        <view class="custom-modal-content tn-flex tn-flex-direction-column tn-flex-col-center"
              style="margin-bottom: 18px;">
          <canvas id="qrcode0" canvas-id="qrcode0" style="width: 30vw; height: 30vw;"></canvas>
          <tn-button class="btn0" @click="downloadPDFFn(0)" backgroundColor="tn-bg-blue"
                     style="width: 100%; margin-top: 16px" fontColor="tn-color-white">作业清单
          </tn-button>
        </view>
        <view class="custom-modal-content tn-flex tn-flex-direction-column tn-flex-col-center"
              style="margin-bottom: 18px;">
          <canvas id="qrcode1" canvas-id="qrcode1" style="width: 30vw; height: 30vw;"></canvas>
          <tn-button class="btn1" @click="downloadPDFFn(1)" backgroundColor="tn-bg-blue"
                     style="width: 100%; margin-top: 16px" fontColor="tn-color-white">收费标准
          </tn-button>
        </view>
      </view>
    </tn-modal>
  </view>
</template>

<script>
import {getJyChargeList, addJyChargeList, getJyChargeDetail, updateJyChargeList} from '@/api/jyChargeList';
import {getJyServiceAgreement} from '@/api/jyServiceAgreement';
import {calc} from 'a-calc/es';

import {chexing} from '@/static/mock/chexing.js';
import {dadiansongshui} from '@/static/mock/dadiansongshui.js';
import dayjs from 'dayjs';
import tuocheMixin from './zuoyemixin/tuoche';
import huanluntaiMixin from './zuoyemixin/huanluntai';
import cheliangzhengxiuMixin from './zuoyemixin/cheliangzhengxiu';
import dadiansongshuiMixin from './zuoyemixin/dadiansongshui';
import cheliangbaoguanMixin from './zuoyemixin/cheliangbaoguan';

import downloadcreatimg from './zuoyemixin/download&creatimg';

import {fillEmptyValuesWithSlash} from '@/utils/formatData.js';
import diaocheCom from "@/pages/rescue/add/zuoyemixin/diaocheCom.vue";
import huowuzhuanyunCom from "@/pages/rescue/add/zuoyemixin/huowuzhuanyunCom.vue";
import huowuzhuangxieCom from "@/pages/rescue/add/zuoyemixin/huowuzhuangxieCom.vue";
import {isUpLst} from "@/static/mock/diaoche";
import {saveNextStep} from "@/pages/rescue/add/funtion";


export default {
  components: {diaocheCom, huowuzhuanyunCom, huowuzhuangxieCom},
  mixins: [
    tuocheMixin
    , huanluntaiMixin
    , cheliangzhengxiuMixin
    , dadiansongshuiMixin
    , cheliangbaoguanMixin
    , downloadcreatimg
  ],
  data() {
    return {
      selectType: 'tc',

      chexingSelectShow: false,
      chexingList: chexing,

      dcSubtotal: 0,
      hwyzSubtotal: 0,
      hwzxJxzxSubtotal: 0,

      dadianSelectShow: false,
      dadianList: dadiansongshui,

      dragAddress: '',
      isUpLst,

      erweima: false,

      form: {
        createTime1: '',
        chexing: '',

        sgxcqlContent: '',
        sgxcqlSubtotal: '',
        cltxContent: '',
        cltxSubtotal: '',
        qtContent: '',
        qtSubtotal: '',

        sumMoneyLower: 0,

        party: '',
        partyTel: '',
        rescueUnit: '',
        rescueUnitTel: '',
        emerg: '',

        clbgCarType: '',
        ddCarType: '',
        dcCarType: '',
        // tcCarType: ''
      },
      rules: {},
    };
  },
  // 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
  onReady() {
    this.form.jyBaseId = this.$route.query.jyBaseId;
    if (this.$route.query.id) {
      this.getList(this.$route.query.id);
    }else{
      //解决 时间不回显问题
      setTimeout(()=>{
        this.form.createTime1 = dayjs().format('YYYY-MM-DD HH:mm:ss')
      },500)
    }
  },
  onNavigationBarButtonTap(e) {
    // 08.12 解决卷宗修改车牌，数据不同步问题
    this.submit('pdf');
  },
  computed: {
    chexing() {
      return chexing
    },

    // 合计
    sumMoneyLower_com() {
      return calc(`${this.tcSubtotal || 0}
      + ${this.dcSubtotal || 0}
			+ ${this.hltSubtotal || 0}
			+  ${this.clzxJqsSubtotal || 0}
			+  ${this.clzxQgSubtotal || 0}
			+  ${this.hwzxJxzxSubtotal || 0}
			+  ${this.hwzxRgzxSubtotal || 0}
			+ ${this.hwyzSubtotal || 0}
			+  ${this.ddSubtotal || 0}
			+  ${this.ssSubtotal || 0}
			+  ${this.clbgSubtotal || 0}
			+  ${this.form.sgxcqlSubtotal || 0}
			+  ${this.form.cltxSubtotal || 0}
			+ ${this.form.qtSubtotal || 0}
			`);
    }
  },
  watch: {
    // 事故现场清理
    'form.sgxcqlContent'(val) {
      if (val) {
        this.form.sgxcqlSubtotal = 500
      } else {
        this.form.sgxcqlSubtotal = ""
      }
    },
  },
  methods: {
    // 修复折叠面板初始化bug
    collapseInit() {
      this.$refs.collapse.init()
    },
    dadianConfirm(val) {
      const obj = dadiansongshui[val[0].value];
      if (this.selectType === 'dadian') {
        this.form.ddCarType = obj.label;
        this.form.ddChargingStandard = obj.basis;
      }

      if (this.selectType === 'songshui') {
        this.form.ssCarType = obj.label;
        this.form.ssChargingStandard = obj.songshui;
      }

      if (this.selectType === 'cheliangbaoguanfei') {
        this.form.clbgCarType = obj.label;
        this.form.clbgChargingStandard = obj.baoguan;
        this.form.clbgGoods = '否'
      }


    },

    clearItem() {
      this.tcCancel()
      this.huantaiCancel()
      this.dadianCancel()
      this.songshuiCancel()
      this.cheliangbaoguanCancel()
    },

    // 拖车
    chexingConfirm(val) {
      if (this.selectType === 'tc') {
        const obj = chexing[val[0].value];
        this.form.tcCarType = obj.label;
        this.form.tcBasePrice = obj.basis;
        this.tcDanjia = obj.work;
        this.form.tcIsUp = '否'
      }
    },
    jupmSign(name) {
      uni.navigateTo({
        url: '/pages/signBoard/signBoard?name=' + name,
        events: {
          // 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
          acceptDataFromOpenedPage: (data) => {
            this.form[data.name] = data.data;
          }
        }
      });
    },
    getQianZi(id) {
      getJyServiceAgreement(id).then((res) => {
        if (res?.data && res?.data?.partyaSign) {
          this.form.party = res.data.partyaSign;
        }
      });
    },
    getList(id) {
      getJyChargeDetail(id).then((res) => {
        if (res.data) {
          // 拖车 回选 故障车型
          const current = chexing.find(item => item.label === res.data.tcCarType)
          current && this.chexingConfirm([current]);

          // 斜杆 转 空串
          const newData = fillEmptyValuesWithSlash(res.data, "/", "")

          // 吊车回显
          this.setDiaoCheData(newData)

          // 转运回显
          this.setZhuanYunData(newData)

          // 装卸回显
          this.setZhuangXieData(newData)


          this.form = newData;
          this.dragAddress = true;
          // 换轮胎
          this.sethltType();
          //修复 后端接参，反参不一致问题
          this.form.createTime1 = this.form.createTime;
        }
        if (!res?.data || !res?.data?.party) {
          // this.getQianZi(id);
        }

      });
    },
    submit(type) {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.clearItem();
          this.form.tcSubtotal = this.tcSubtotal
          this.form.hltSubtotal = this.hltSubtotal
          this.form.clzxJqsSubtotal = this.clzxJqsSubtotal
          this.form.clzxQgSubtotal = this.clzxQgSubtotal
          this.form.ddSubtotal = this.ddSubtotal
          this.form.ssSubtotal = this.ssSubtotal
          this.form.clbgSubtotal = this.clbgSubtotal

          this.form.sumMoneyLower = this.sumMoneyLower_com
          // 吊车数据 数组转字符串
          const diaocheForm = {
            dcType: this.$refs.diaoche.formatList.map(item => item.dcType === "" ? "/" : item.dcType).join(","),
            dcCarType: this.$refs.diaoche.formatList.map(item => item.dcCarType === "" ? "/" : item.dcCarType).join(","),
            dcChargingStandard: this.$refs.diaoche.formatList.map(item => item.dcChargingStandard === "" ? "/" : item.dcChargingStandard).join(","),
            dcIsUp: this.$refs.diaoche.formatList.map(item => item.dcIsUp === "" ? "/" : item.dcIsUp).join(","),
            dcSubtotal: this.$refs.diaoche.formatList.map(item => item.dcSubtotal ? item.dcSubtotal : "/").join(",")
          }

          // 货物转运数据 数组转字符串
          const huowuzhuanyunForm = {
            hwyzTons: this.$refs.huowuzhuanyun.formatList.map(item => item.hwyzTons === "" ? "/" : item.hwyzTons).join(","),
            hwyzChargingStandard: this.$refs.huowuzhuanyun.formatList.map(item => item.hwyzChargingStandard).join(","),
            hwyzIsUp: this.$refs.huowuzhuanyun.formatList.map(item => item.hwyzIsUp).join(","),
            hwyzSubtotal: this.$refs.huowuzhuanyun.formatList.map(item => item.hwyzSubtotal).join(",")
          }

          // 货物装卸数据 数组转字符串
          const huowuzhuangxieForm = {
            hwzxJxzxCount: this.$refs.huowuzhuangxie.formatList.map(item => item.hwzxJxzxCount === "" ? "/" : item.hwzxJxzxCount).join(","),
            hwzxJxzxChargingStandard: this.$refs.huowuzhuangxie.formatList.map(item => item.hwzxJxzxChargingStandard).join(","),
            hwzxJxzxIsUp: this.$refs.huowuzhuangxie.formatList.map(item => item.hwzxJxzxIsUp).join(","),
            hwzxJxzxSubtotal: this.$refs.huowuzhuangxie.formatList.map(item => item.hwzxJxzxSubtotal).join(","),

            hwzxRgzxCount: this.$refs.huowuzhuangxie.form2.hwzxRgzxCount,
            hwzxRgzxChargingStandard: this.$refs.huowuzhuangxie.form2.hwzxRgzxChargingStandard,
            hwzxRgzxIsUp: this.$refs.huowuzhuangxie.form2.hwzxRgzxIsUp,
            hwzxRgzxSubtotal: this.$refs.huowuzhuangxie.form2.hwzxRgzxSubtotal,
          }

          this.form = {
            ...this.form,
            ...diaocheForm,
            ...huowuzhuanyunForm,
            ...huowuzhuangxieForm
          };

          let newForm = fillEmptyValuesWithSlash(this.form)
          newForm = {
            ...newForm,
            pdfUrl: this.form.pdfUrl,
            party: this.form.party,
            partyTel: this.form.partyTel,
            emerg: this.form.emerg,
            emergTel: this.form.emergTel,
            rescueUnit: this.form.rescueUnit,
            rescueUnitTel: this.form.rescueUnitTel,
          };
          addJyChargeList(newForm).then((res) => {
            // 解决 pdf 下载问题
            this.form.id = res.data.id;

            saveNextStep(type, res, this)
          });
          console.log('验证通过');
        } else {
          console.log('验证失败');
        }
      });
    },
    setDiaoCheData(newData) {
      const list = []
      let dcSubtotal = newData.dcSubtotal.split(",")
      let dcIsUp = newData.dcIsUp.split(",")
      let dcChargingStandard = newData.dcChargingStandard.split(",")
      let dcCarType = newData.dcCarType.split(",")
      let dcType = newData.dcType.split(",")
      dcSubtotal.forEach((item, index) => {
        if (+dcSubtotal[index] && dcSubtotal[index] !== '/') {
          list.push({
            dcSubtotal: dcSubtotal[index],
            dcIsUp: dcIsUp[index],
            dcChargingStandard: dcChargingStandard[index],
            dcCarType: dcCarType[index],
            dcType: dcType[index]
          })
        }
      })
      this.$refs.diaoche.formatList = list
      this.$refs.collapse.init();
    },
    setZhuanYunData(newData) {
      const list = []
      let hwyzSubtotal = newData.hwyzSubtotal.split(",")
      let hwyzIsUp = newData.hwyzIsUp.split(",")
      let hwyzChargingStandard = newData.hwyzChargingStandard.split(",")
      let hwyzTons = newData.hwyzTons.split(",")
      hwyzSubtotal.forEach((item, index) => {
        if (hwyzSubtotal[index]) {
          list.push({
            hwyzSubtotal: hwyzSubtotal[index],
            hwyzIsUp: hwyzIsUp[index],
            hwyzChargingStandard: hwyzChargingStandard[index],
            hwyzTons: hwyzTons[index],
          })
        }
      })
      this.$refs.huowuzhuanyun.formatList = list
      this.$refs.collapse.init();
    },
    setZhuangXieData(newData) {
      const list = []
      let hwzxJxzxSubtotal = newData.hwzxJxzxSubtotal.split(",")
      let hwzxJxzxIsUp = newData.hwzxJxzxIsUp.split(",")
      let hwzxJxzxChargingStandard = newData.hwzxJxzxChargingStandard.split(",")
      let hwzxJxzxCount = newData.hwzxJxzxCount.split(",")
      hwzxJxzxSubtotal.forEach((item, index) => {
        if (hwzxJxzxSubtotal[index]) {
          list.push({
            hwzxJxzxSubtotal: hwzxJxzxSubtotal[index],
            hwzxJxzxIsUp: hwzxJxzxIsUp[index],
            hwzxJxzxChargingStandard: hwzxJxzxChargingStandard[index],
            hwzxJxzxCount: hwzxJxzxCount[index],
          })
        }
      })
      this.$refs.huowuzhuangxie.formatList = list
      this.$refs.collapse.init();

      this.$refs.huowuzhuangxie.form2 = {
        hwzxRgzxCount: newData.hwzxRgzxCount,
        hwzxRgzxChargingStandard: newData.hwzxRgzxChargingStandard,
        hwzxRgzxIsUp: newData.hwzxRgzxIsUp,
        hwzxRgzxSubtotal: newData.hwzxRgzxSubtotal,
      }
      // 修复 上浮选中问题
      setTimeout(()=>{
        this.$refs.huowuzhuangxie.form2.hwzxRgzxIsUp = newData.hwzxRgzxIsUp;
      },500)
    }
  }
};
</script>

<style lang="scss" scoped>
@import './zuoyemixin/zuoye';
</style>
